package com.example.rbacmanage.service.impl;

import com.example.rbacmanage.entity.UserPost;
import com.example.rbacmanage.exception.MyException;
import com.example.rbacmanage.service.UserPostService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.rbacmanage.mapper.UserPostMapper;
import java.util.List;

/**
 * 用户岗位服务实现类
 *
 * @author zmd
 */
@Service
public class UserPostServiceImpl  implements UserPostService {
    @Autowired
    private UserPostMapper  userPostMapper;

    @Override
    public void save(UserPost userPost) {
            userPostMapper.insert(userPost);
    }

    @Override
    public void remove(Long[] ids) {
        for(Long id:ids){
                userPostMapper.del(id);
        }
    }

    @Override
    public void update(UserPost userPost) {
            userPostMapper.update(userPost);
    }

    @Override
    public List<UserPost> getAll(UserPost userPost) {
        return userPostMapper.list(userPost);
    }

    @Override
    public PageInfo<UserPost> getPage(UserPost userPost) {
        PageHelper.startPage(userPost.getPage(), userPost.getLimit());
        return new PageInfo<>(userPostMapper.list(userPost));
    }

    @Override
    public UserPost getById(Long id) {
        return userPostMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(UserPost userPost) {
        return userPostMapper.count(userPost);
    }

    @Override
    public void checkRepeat(UserPost userPost) throws MyException {

    }
}
